<%@ page import="com.cindata.DateUtil" %>
<!DOCTYPE html>
<html>
<head>
    <meta name="layout" content="main" />
    <meta name="viewport" content="width=device-width, initial-scale=1, minimum-scale=1, maximum-scale=1, user-scalable=no">
    <g:set var="entityName" value="${message(code: 'estate.label', default: 'Estate')}" />
    <title>逾期/违约（对公）</title>
    <style>
    .contact-stat{
        padding: 8px 0px;
        text-align: center;
    }
    .contact-stat span{
        font-size: 13px;
        color: #88898c;
        margin-bottom: 10px;
    }
    .contact-stat strong{
        font-size: 13px;
        word-wrap: break-word;
    }
    .nav-tabs{
        border-bottom: none;
    }
    .hpanel > .panel-footer, .hpanel > .panel-section{
        background: #f9f9f9;
    }

    .newFontSize{
        font-size: 12px;
    }
    table>tbody>tr>td, table>tbody>tr>th,.table>tfoot>tr>td, table>tfoot>tr>th, table>thead>tr>td, table>thead>tr>th{
        padding: 8px;
        line-height: 1.42857143;
    }

    </style>
</head>
<body class="fixed-navbar fixed-sidebar">

<div class="small-header">
    <div class="hpanel">
        <div class="panel-body">
            <div id="hbreadcrumb" class="pull-right">
                <ol class="hbreadcrumb breadcrumb">
                    <li>CINDATA PLS</li>
                    <li class="active">
                        <span>逾期/违约（对公）</span>
                    </li>
                </ol>
            </div>

            <h2 class="font-light m-b-xs">
                逾期/违约（对公）
            </h2>
        </div>
    </div>
</div>

<div class="content animate-panel">
    <div class="row">
        <g:form method="POST" action="accountOverdueWarning" class="form-horizontal" role="form" id="form">
            <div class="hpanel hblue">
                <div class="panel-heading">
                    <div class="panel-tools">
                        <button class="btn btn-primary btn-xs" type="submit" id="searchBtn"><i class="fa fa-search"></i> 查询</button>
                        <button class="btn btn-warning2 btn-xs" type="button" id="resetBtn">
                            <i class="fa fa-times"></i> 重置</button>
                    </div>
                    查询
                </div>
             <div class="panel-body seach-group" id="bug1">

        %{--第一行--}%
                <div class="row">
                    <div class="form-group col-sm-3">
                        <label for="city" class="col-sm-3 control-label">城市</label>
                        <div class="col-sm-9">
                            <g:select class="form-control" name="city" id="city"
                                      from="${com.cindata.City.findAllByNameInList(new com.cindata.ComponentService().evaluate(com.cindata.Component.findByCode('showCity')), [sort: 'name', order: 'asc'])}"
                                      valueMessagePrefix="status" optionKey="zoneNumber" optionValue="name"
                                      value="${params?.city}"
                                      noSelection="${["-1": '请选择城市']}"/>
                            <input type="hidden" id="communityId" value="${params?.communityId}" name="communityId" />
                        </div>
                    </div>
                    <div class="form-group col-sm-3">
                        <label class="col-sm-3 control-label">经营状态</label>
                        <div class="col-sm-9 input-group" style="display: flex;justify-content: center">
                            <g:select class="form-control" name="operatingState" id="operatingState"
                                      from="${com.cindata.Account.constrainedProperties.operatingState.inList}"
                                      value="${params?.operatingState}"
                                      noSelection="${['': '请选择经营状态']}"/>
                        </div>
                    </div>
                    <div class="form-group col-sm-3">
                        <label class="col-sm-3 control-label">信用等级</label>
                        <div class="col-sm-9 input-group" style="display: flex;justify-content: center">
                            <input type="text" class="form-control" name="creditLevel" id="creditLevel" value="${params?.creditLevel}" placeholder="请输入信用等级">
                        </div>
                    </div>
                    <div class="form-group col-sm-3">
                        <label class="col-sm-3 control-label">注册资金</label>
                        <div class="col-sm-7 input-group ">
                            <input type="text" class=" form-control " placeholder="请输入下限" maxlength="6"
                                   id="registeredCapitalStart" value="${params?.registeredCapitalStart}" name="registeredCapitalStart" />
                            <span class="input-group-addon">至</span>
                            <input type="text" class=" form-control " placeholder="请输入上限" maxlength="6"
                                   id="registeredCapitalEnd" value="${params?.registeredCapitalEnd}" name="registeredCapitalEnd" />
                        </div>
                        <div class="col-sm-2 p-t-xss">
                            万元
                        </div>
                    </div>
                </div>
            %{--第二行--}%
                <div class="row">
                    <div class="form-group col-sm-3">
                        <label class="col-sm-3 control-label">企业名称</label>
                        <div class="col-sm-9">
                            <input type="text" class="form-control" name="name" id="name" value="${params?.name}" placeholder="请输入企业名称">
                        </div>
                    </div>
                    <div class="form-group col-sm-3">
                        <label class="col-sm-3 control-label">单位性质</label>
                        <div class="col-sm-9 input-group" style="display: flex;justify-content: center">
                            <g:select class="form-control" name="unitNature" id="unitNature"
                                      from="${com.cindata.dictionary.OrganizationNatureDict.list()}"
                                      valueMessagePrefix="status" optionKey="id" optionValue="name"
                                      value="${params?.unitNature}"
                                      noSelection="${['': '请选择单位性质']}"/>
                        </div>
                    </div>
                    <div class="form-group col-sm-3">
                        <label  class="col-sm-3 control-label">违约期数</label>
                        <div class="col-sm-7  input-group">
                            <input type="text" class=" form-control "
                                   placeholder="请输入下限" id="defaultStart" maxlength="6"
                                   value="${params?.defaultStart}" name="defaultStart" />
                            <span class="input-group-addon">至</span>
                            <input type="text" class="form-control " placeholder="请输入上限" maxlength="6"
                                   id="defaultEnd"  value="${params?.defaultEnd}" name="defaultEnd" />
                        </div>
                        <div class="col-sm-2 p-t-xss">
                            次数
                        </div>
                    </div>
                    <div class="form-group col-sm-3">
                        <label  class="col-sm-3 control-label">逾期期数</label>
                        <div class="col-sm-7  input-group">
                            <input type="text" class=" form-control "
                                   placeholder="请输入下限" id="overdueStart" maxlength="6"
                                   value="${params?.overdueStart}" name="overdueStart" />
                            <span class="input-group-addon">至</span>
                            <input type="text" class="form-control " placeholder="请输入上限" maxlength="6"
                                   id="overdueEnd"  value="${params?.overdueEnd}" name="overdueEnd" />
                        </div>
                        <div class="col-sm-2 p-t-xss">
                            次数
                        </div>
                    </div>
                </div>
            </div>
        </g:form>
    </div>
    </div>

    <div class="row" id="accountList">
        <div class="hpanel hgreen">
            <div class="panel-heading">
                <div class="panel-tools">
                    %{--<a class="btn btn-primary btn-xs" type="submit" href="/riskWarning/releasePriceFluctuationsWarning"><i class="fa fa-paper-plane"></i> 发布预警</a>--}%
                    %{--<button class="btn btn-warning2 btn-xs" type="submit" onclick="searchMap()"><i class="fa fa-map-marker"></i> 查看地图</button>--}%
                    <a class="showhide"><i class="fa fa-chevron-up"></i></a>
                </div>
                全部逾期/违约列表（对公）
            </div>
            <div class="panel-body no-padding">
                <div class="table-responsive">
                    <table cellpadding="1" cellspacing="1" class="table table-striped table-bordered table-hover text-center" id="estateTable">
                        <thead>
                        <tr>
                            <g:sortableColumn property="name" title="企业名称"  class="col-md-1 text-center" params="${params}"/>
                            <g:sortableColumn property="city" title="城市"  class="col-md-1 text-center" params="${params}"/>
                            <g:sortableColumn property="district" title="行政区"  class="col-md-1 text-center" params="${params}"/>
                            <g:sortableColumn property="unitNature" title="单位性质"  class=" col-md-1 text-center" params="${params}"/>
                            <g:sortableColumn property="phone" title="公司电话"  class=" col-md-1 text-center" params="${params}"/>
                            <g:sortableColumn property="operatingState" title="经营状态"  class=" col-md-1 text-center" params="${params}"/>
                            <g:sortableColumn property="operatingState" title="信用等级"  class=" col-md-1 text-center" params="${params}"/>
                            <g:sortableColumn property="registeredCapital" title="注册资金"  class=" col-md-1 text-center" params="${params}"/>
                            <g:sortableColumn property="creditAmount" title="信用额度"  class=" col-md-1 text-center" params="${params}"/>
                            <g:sortableColumn property="creditBalance" title="信用余额"  class=" col-md-1 text-center" params="${params}"/>
                            <g:sortableColumn property="creditBalance" title="违约期数"  class=" col-md-1 text-center" params="${params}"/>
                            <g:sortableColumn property="creditBalance" title="逾期期数"  class=" col-md-1 text-center" params="${params}"/>
                            <g:sortableColumn property="creditBalance" title="处置状态"  class=" col-md-1 text-center" params="${params}"/>
                            <th class="col-md-1 text-center sortable" style="color: #34495e;" colspan="2">操作项</th>
                        </tr>
                        </thead>
                        <tbody>
                        %{--<g:each in="${accountList}">--}%
                            <tr>
                                <td class="text-center"><g:link style="color: #3498DB" action="accountOverdueWarningShow" id = '1' class="firstTd">XX住房置业担保有限公司</g:link></td>
                                <td class="text-center" >北京市</td>
                                <td class="text-center">昌平区</td>
                                <td class="text-center">有限责任公司</td>
                                <td class="text-center">010-23647365</td>
                                <td class="text-center">清算</td>
                                <td class="text-center">100000000.00</td>
                                <td class="text-center">83546411.00</td>
                                <td class="text-center">36464</td>
                                <td class="text-center">5</td>
                                <td class="text-center">1</td>
                                <td class="text-center">已处置</td>
                                <td class="text-center">
                                    <div style="margin-bottom: 2px;">
                                        <div class="btn btn-xs btn-outline btn-success" style="color: #fff" disabled>
                                            已处置
                                        </div>
                                    </div>
                                </td>
                                <td class="text-center">
                                    <div class="btn btn-xs btn-outline btn-danger" style="width: 52px; margin-top: 2px;color: #fff" disabled>
                                        删除
                                    </div>
                                </td>
                            </tr>
                            <tr>
                                <td class="text-center"><g:link style="color: #3498DB" action="accountOverdueWarningShow" id = '2' class="firstTd">XX科技有限公司</g:link></td>
                                <td class="text-center" >北京市</td>
                                <td class="text-center">海淀区</td>
                                <td class="text-center">股份有限公司</td>
                                <td class="text-center"> 010-58868888 </td>
                                <td class="text-center">存续</td>
                                <td class="text-center">120000000.00</td>
                                <td class="text-center">136546411.00</td>
                                <td class="text-center">43290</td>
                                <td class="text-center">5</td>
                                <td class="text-center">1</td>
                                <td class="text-center">已处置</td>
                                <td class="text-center">
                                    <div style="margin-bottom: 2px;">
                                        <div class="btn btn-xs btn-outline btn-success" style="color: #fff" disabled>
                                            已处置
                                        </div>
                                    </div>
                                </td>
                                <td class="text-center">
                                    <div class="btn btn-xs btn-outline btn-danger" style="width: 52px; margin-top: 2px;color: #fff" disabled>
                                        删除
                                    </div>
                                </td>
                            </tr>
                            <tr>
                                <td class="text-center"><g:link style="color: #3498DB" action="accountOverdueWarningShow" id = '3' class="firstTd">XX房地产评估有限公司</g:link></td>
                                <td class="text-center" >北京市</td>
                                <td class="text-center">海淀区</td>
                                <td class="text-center">股份有限公司</td>
                                <td class="text-center">010-28826666</td>
                                <td class="text-center">存续</td>
                                <td class="text-center">150000000.00</td>
                                <td class="text-center">135364311.00</td>
                                <td class="text-center">764382</td>
                                <td class="text-center">5</td>
                                <td class="text-center">1</td>
                                <td class="text-center">已发布</td>
                                <td class="text-center">
                                    <div style="margin-bottom: 2px;">
                                        <a href="#" class="btn btn-xs btn-outline btn-success handleButton">
                                            已处置
                                        </a>
                                    </div>
                                </td>
                                <td class="text-center">
                                    <a href="#" class="btn btn-xs btn-outline btn-danger deleteButton" style="width: 52px; margin-top: 2px;">
                                        删除
                                    </a>
                                </td>
                            </tr>
                        %{--</g:each>--}%
                        </tbody>
                    </table>
                </div>
            </div>
            <div class="panel-footer">
                <div class="pagination">
                    %{--<g:paginate action="accountOverdueWarning" total="${accountCount ?: 0}" params="${params}"/>--}%
                </div>
            </div>
        </div>
    </div>

</div>

<script>
    $(".handleButton").click(function(event){
        event.preventDefault();
        var id = $(this).attr("href");
        swal({
                title: "该公司已经完成预警处置吗？",
                type: "warning",
                showCancelButton: true,
                confirmButtonColor: "#DD6B55",
                confirmButtonText: "确定",
                cancelButtonText: "取消",
                closeOnConfirm: true
            },
            function(){
                $.ajax({
                    url:'',
                    data:{
                        id:id
                    },
                    type:"post",
                    success:function(data)
                    {
                        // if(data.status=="success"){
                        //     window.location.href="/riskWarning/dealIndex"
                        // }else{
                        //     swal("已处置失败，请稍后重试", "", "error");
                        // }
                    }
                })

            });
    });
    $(".deleteButton").click(function(event){
        event.preventDefault();
        var id = $(this).attr("href");
//        var $this = $(this);
        swal({
                title: "确定删除该公司的预警处置吗？",
                type: "warning",
                showCancelButton: true,
                confirmButtonColor: "#DD6B55",
                confirmButtonText: "确定",
                cancelButtonText: "取消",
                closeOnConfirm: true
            },
            function(){
                $.ajax({
                    url:'',
                    data:{
                        id:id
                    },
                    type:"post",
                    success:function(data)
                    {
//                         if(data.status=="success"){
//                             $("#searchBtn").click();
// //                            window.location.reload();//刷新页面
// //                            var link = $this.parents("tr");
// //                            link.remove();//删除行
//                         }else{
//                             swal("删除失败，请稍后重试", "", "error");
//                         }
                    }
                })
            })
    });
    //城市切换
    $("#city").bind("change", function(){
        $("#district option").remove();
        $("#s2id_district span:first").html("请选择行政区");
        var city = $("#city").val();
        $("#district").append("<option value='-1' >请选择行政区</option>");
        if(city=='-1'){
            return
        }
        $.ajax({
            url: "/estate/districtList",
            type: "POST",
            data: {'city': city} ,
            success: function(result){
                for(var i=0; i < result.districtList.length; i++){
                    $("#district").append("<option value=" + result.districtList[i].zoneNumber + ">" + result.districtList[i].name + "</option>")
                }
            }
        });
    });
    // $("#city").change();
    //条件重置
    $("#resetBtn").click(function () {
        $("#s2id_city span:first").html("请选择城市");
        $("#city").val("");
        $("#registeredCapitalStart").val("");
        $("#registeredCapitalEnd").val("");
        $("#name").val("");
        $("#creditLevel").val("");
        $("#s2id_operatingState span:first").html("请选择经营状态");
        $("#operatingState").val("");
        $("#s2id_unitNature span:first").html("请选择单位性质");
        $("#unitNature").val("");
        $("#s2id_overdueType span:first").html("个人");
        $("#overdueType").val("");
        $("#defaultStart").val("");
        $("#defaultEnd").val("");
        $("#overdueStart").val("");
        $("#overdueEnd").val("");

    });
    //查看地图
    function searchMap() {
        var risk=$("#risk").val(),
            city=$('#city').val(),
            district=$('#district').val(),
            precinct=$('#precinct').val(),
            inputData={
                risk:risk,
                city:city,
                district:district,
                precinct:precinct
            };
        if(city=="-1"){
            toastr.error('请选择城市！');
            return
        }
        //window.location.href="/map/cluster?currentMap=clusterMap&flag=true&city="+$("#city").val()+"&district="+$("#district").val()+"&communityId="+$("#communityId").val();
        window.location.href="/newMap/cluster?currentMap=clusterMap&city="+$("#city").val()+"&district="+$("#district").val()+"&communityId="+$("#communityId").val();
    }
</script>

</body>
</html>
